<?php
namespace App\Http\Resources\Trade\Index;

use App\Http\Resources\ResourceCollection;
use App\Services\Utils\TencentYun\ImageService;

class KindListSupplyResource extends ResourceCollection
{

    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request            
     * @return array
     */
    public function toArray($request)
    {
        return $this->collection->map(function ($item, $key) {
            return self::makeDataDecode($item);
        })->toArray();
    }

    /**
     * 制作使用数据（一条）
     */
    public static function makeDataDecode($data)
    {
        // 图片
        $data['img_view'] = ImageService::makeDownloadUri($data['img'], ImageService::BUCKET_TRADE);
        // 跳转链接
        // $data['uri'] = route('supplyList');
        return $data;
    }
}
